QuickTime 3 Reference

Previous | Chapter Top | Chapter Contents | Next

Copying Existing Atoms

QuickTime provides several functions for copying existing atoms within an atom container. The QTInsertChildren function inserts a container of atoms as children of a parent atom in another atom container. Figure 8 shows two example QT atom containers, A and B.

Figure 8 Two QT atom containers, A and B

The following code sample calls QTFindChildByID to retrieve the offset of the atom in container A. Then, the code sample calls the QTInsertChildren function to insert the atoms in container B as children of the atom in container A. Figure 9 shows what container A looks like after the atoms from container B have been inserted.

QTAtom targetAtom;

targetAtom = QTFindChildByID (containerA, kParentAtomIsContainer, 'abcd',
    1000, nil);

FailOSErr (QTInsertChildren (containerA, targetAtom, containerB));

Figure 9 QT atom container after child atoms have been inserted

In Listing 9 , the QTInsertChild function inserts a parent atom into the atom container theSample . Then, the sample code calls QTInsertChildren to insert the container theSprite into the container theSample . The parent atom is newSpriteAtom .

Listing 9 Inserting a container into another container

FailOSErr (QTInsertChild (theSample, kParentAtomIsContainer,
    kSpriteAtomType, spriteID, 0, 0, nil, &newSpriteAtom));

FailOSErr (QTInsertChildren (theSample, newSpriteAtom, theSprite));

QuickTime provides three other functions you can use to manipulate atoms in an atom container. The QTReplaceAtom function replaces an atom and its children with a different atom and its children. You can call the QTSwapAtoms function to swap the contents of two atoms in an atom container; after swapping, the ID and index of each atom remains the same. The QTCopyAtom function copies an atom and its children to a new atom container.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next